function setCurrentPos(){
	//清除定位点
    $$('.current-icon').hide();
    //添加新的定位点
    var cbx = parseInt($$('.current-icon').data('blockX'));
    var cby = parseInt($$('.current-icon').data('blockY'));
	var currentTop = cby*netrectH-currenticonSize/2+netrectH/2;
    var currentLeft = cbx*netrectW-currenticonSize/2+netrectW/2;
    //console.log(currentblock,netrectW,netrectH)
    $$('.current-icon').transform('translate('+currentLeft+'px,'+currentTop+'px)');
    $$('.current-icon').addClass('active');
    $$('.current-icon').show();
}

function getPathBlocks(blocks,start,end){
	grid = new PF.Grid(blocks);
    finder = new PF.AStarFinder({
    	allowDiagonal: true,
    	dontCrossCorners: true,
    	heuristic:PF.Heuristic.chebyshev
    });
    var path = finder.findPath(start[0], start[1], end[0], end[1], grid);
    path = PF.Util.smoothenPath(grid, path);
    return path;
}

function drawRoute(path){
	//清空画布并重新绘制路径
	$$('#floor-canvas').attr('height',mapH);
	//获取起点
	var startposX = path[0][0]*netrectW+netrectW/2;
	var startposY = path[0][1]*netrectH+netrectH/2;
	//console.log(startposX,startposY);
	ctx.beginPath();
	ctx.strokeStyle = '#0000FF';//轮廓颜色
	ctx.lineWidth = 2;//路径宽度
    ctx.moveTo(startposX,startposY);//设置起点
    //console.log("起点=>"+startposX+' '+startposY);
    //绘制路径
	var bindex;
	for(bindex in path){
		var tragetX = path[bindex][0]*netrectW+netrectW/2;
		var tragetY = path[bindex][1]*netrectH+netrectH/2;
		ctx.lineTo(tragetX,tragetY);
   		//console.log(tragetX,tragetY);
	}
	ctx.stroke();
	//清空起点终点
	startBlock = null;
    endBlock = null;
}

function findPath(){
	pathroute = getPathBlocks(blocks1,startBlock,endBlock);
	//绘制路径
    drawRoute(pathroute);
}

function setMarkerPos(markerselector,tapCenter,scale){
	var mapCtop  = parseFloat($$('.map-container').data('axisY'));
    var mapCleft = parseFloat($$('.map-container').data('axisX'));
    var mapCfloor = $$('.map-container').data('floor');
    //map-container中心点坐标(不随transform变换)
    var mapCenterX = mapW/2+mapCleft;
    var mapCenterY = mapH/2+mapCtop;
    //当前的map-container左上角顶点坐标
    var mapNewX = mapCenterX-mapW/2*scale;
    var mapNewY = mapCenterY-mapH/2*scale;
    //marker所处网格坐标
    var markerblockX = Math.round((tapCenter.x-mapNewX)/netrectW/scale)-1;
	var markerblockY = Math.round((tapCenter.y-mapNewY)/netrectH/scale)-1;
	//marker在父元素map-container变换前的坐标（相对于地图左上角顶点）
	var mleft = (markerblockX+1)*netrectW-netrectW/2-markerSize/2;
	var mtop  = (markerblockY+1)*netrectH-netrectH/2-markerSize;
	//console.log(markerblockX,markerblockY);
	//marker真实坐标
	var markerRealX = (tapCenter.x-mapNewX)/scale*mapRatioW;
	var markerRealY = (tapCenter.y-mapNewY)/scale*mapRatioH;
	//判断是否可选,并设定marker
	switch(mapCfloor){
		case '1':
			var cblocs = blocks1;
			break;
		default:
			var cblocs = '';
	}
	if(cblocs){
		if(cblocs[markerblockY][markerblockX] == 0){
			//设定楼层
			$$(markerselector).attr('floor',mapCfloor);
			//设定位置
			$$(markerselector).transform('translate('+mleft+'px,'+mtop+'px)');
			$$(markerselector).addClass('active');
			$$(markerselector).show();
			var markerdisplay = true;
		}else{
			var markerdisplay = false;
		}
	}else{
		var markerdisplay = false;
	}
    //console.log('map('+mapNewX+','+mapNewY+');mapCenter('+mapCenterX+','+mapCenterY+');tap('+tapCenter.x+','+tapCenter.y+');scale('+scale+')');
    return {'markerdisplay':markerdisplay,'markerfloor':mapCfloor,'markerblock':[markerblockX,markerblockY],'markerpos':{'x':mleft,'y':mtop},'markerrealpos':{'x':markerRealX.toFixed(2),'y':markerRealY.toFixed(2)}};	
}